package com.agv.core.lectorDeGlobalizadoresImpl;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import javax.sql.DataSource;

import org.apache.log4j.Logger;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcCall;

public class EjemploDAO {

	private SimpleJdbcCall simpleJdbcCall;
	private SimpleJdbcCall procReadActor;
	private DataSource source;

	/** Componente de logeo para la clase */
	private static final Logger log = Logger.getLogger(Rutas.class); 

	// private CallableStatement cs;

	public void setProcReadActor() {
		log.debug(source.toString());
		this.simpleJdbcCall = new SimpleJdbcCall(source);
		this.procReadActor = new SimpleJdbcCall(source)
				.withProcedureName("ctb.store_prueba");
	}

	public void call() {

		SqlParameterSource in = new MapSqlParameterSource().addValue("", 1)
				.addValue("", "hola");

		Map out = procReadActor.execute(in);
		Iterator it = out.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry m = (Entry) it.next();
			log.debug(m.getKey() + "\t" + m.getValue());

		}
	}

	public void setSource(DataSource source) {
		this.source = source;
	}
}
